import common from './public.js'
$(function () {
	$("#task-fulfil-familyHealth").change(function(){
		if($("#task-fulfil-familyHealth option:selected").val() === "1"){
			$("#task-fulfil-familyHealthDetails").removeAttr("hidden")
		}else if ($("#task-fulfil-familyHealth option:selected").val() === "0") {
			console.log("w");
			$("#task-fulfil-familyHealthDetails").attr("hidden", true)
		}
	})
	$("#task-fulfil-oneselfHealth").change(function(){
		if($("#task-fulfil-oneselfHealth option:selected").val() === "1"){
			$("#task-fulfil-oneselfHealthDetails").removeAttr("hidden")
		}else if ($("#task-fulfil-oneselfHealth option:selected").val() === "0") {
			console.log("w");
			$("#task-fulfil-oneselfHealthDetails").attr("hidden", true)
		}
	})
	// $("#task-fulfil-submit-btn").click(function (){
	// 	common.post("/task/fulfil.do", {
	// 		id: $(".task-fulfil-id"),
	// 		temperature: $(".task-fulfil-temperature"),
	// 		oneselfHealth: $(".task-fulfil-oneselfHealth"),
	// 		oneselfHealthDetails: $(".task-fulfil-oneselfHealthDetails"),
	// 		address: $(".task-fulfil-address"),
	// 		router: $(".task-fulfil-router"),
	// 		familyHealth: $(".task-fulfil-familyHealth"),
	// 		familyHealthDetails: $(".task-fulfil-familyHealthDetails")
	// 	}, function (res){
	// 		if(res.code === 200){
	// 			$("#fulfilTaskModal").modal("hide")
	// 			window.location.href = common.baseUrl + "/task/list.do";
	// 		}else{
	// 			common.promptError(res.msg)
	// 		}
	// 	})
	// })
	$("#task-fulfil-submit-btn").click(function (){
		var announceId = $("#task-fulfil-id").val();
		var temperature = $("#task-fulfil-temperature").val();
		var oneselfHealth = $("#task-fulfil-oneselfHealth").val();
		if(oneselfHealth === "0"){
			oneselfHealth = "健康"
		}else if(oneselfHealth === "1"){
			oneselfHealth = "异常"
		}
		var oneselfHealthDetails = $("#task-fulfil-oneselfHealthDetails").val();
		if(oneselfHealthDetails === "" || oneselfHealthDetails === null){
			oneselfHealthDetails = oneselfHealth;
		}
		var address = $("#task-fulfil-address").val();
		var route = $("#task-fulfil-route").val();
		if(route === "" || route === null){
			route = "暂无"
		}
		var familyHealth = $("#task-fulfil-familyHealth").val();
		if(familyHealth === "0"){
			familyHealth = "健康"
		}else if(familyHealth === "1"){
			familyHealth = "异常"
		}
		var familyHealthDetails = $("#task-fulfil-familyHealthDetails").val();
		if(familyHealthDetails === "" || familyHealthDetails === null){
			familyHealthDetails = familyHealth;
		}
		common.post("/report/add.do", {
			announceId,
			temperature,
			oneselfHealth,
			oneselfHealthDetails,
			address,
			route,
			familyHealth,
			familyHealthDetails
		}, function (res){
			if(res.code === 200){
				common.promptSuccess(res.msg)
				$("#fulfilTaskModal").modal("hide")
				window.location.href = common.baseUrl + "/task/list.do";
			}else{
				common.promptError(res.msg)
			}
		})
	})
})